package com.burgeon.backend.SHOPBACKEND.controller;

import com.burgeon.backend.SHOPBACKEND.entity.IndexCoupon;
import com.burgeon.backend.SHOPBACKEND.service.BackendIndexCouponService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("backend/indexCoupon")
public class BackendIndexCouponController extends BaseController{
    @Autowired
    private BackendIndexCouponService backendIndexCouponService;

    //查看首页优惠卷
    @RequestMapping("findIndexCoupon")
    public ResponseResult<List<IndexCoupon>> findIndexCoupon(String account){
       List<IndexCoupon> data = backendIndexCouponService.findIndexCoupon(account);
       return new ResponseResult<>(SUCCESS,data);
    }

    //新增首页优惠卷
    @RequestMapping("addIndexCoupon")
    public ResponseResult<Void> addIndexCoupon(IndexCoupon indexCoupon,String account){
        backendIndexCouponService.addIndexCoupon(indexCoupon,account);
        return new ResponseResult<>(SUCCESS);
    }

    //删除首页优惠卷根据id
    @RequestMapping("del")
    public ResponseResult<Void> deleteIndexCoupon(String id){
        backendIndexCouponService.deleteIndexCoupon(id);
        return new ResponseResult<>(SUCCESS);
    }


}
